package com.projectCommon.bean.result;

/**
 * @author 吴宇~
 * @motto 我亦无他，唯手熟尔。
 * @edition jdk1.8
 * @reflection 0-1 喧闹任其喧闹，自由我自为之，我自风情万种，与世无争。
 * @date 2023/12/16/14:34
 * @target 心若有所向往，何惧道阻且长
 */
//  可以尝试将 返回码和返回信息定义为枚举。
//TODO:  在里面创建结果对象？？？？ 还是使用构造器？？？？  统一返回时候的结果集！！
public class Result {
    //    结果码为200成功 .为700失败 搞一个可以结果集的枚举.  有结果码和返回信息
    private String respCode;
    private String respMessage;
    private Object data;



    public Result() {
    }


    public static Result success(){
        Result result = new Result();
        result.setData(null);
        result.setRespCode(CODE.SUCCESS);
        result.setRespMessage("执行成功");
        return result;
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.setData(data);
        result.setRespCode(CODE.SUCCESS);
        result.setRespMessage("执行成功");
        return result;
    }

    public static Result success(Object data, String respMessage) {
        Result result = new Result();
        result.setData(data);
        result.setRespCode(CODE.SUCCESS);
        result.setRespMessage(respMessage);
        return result;
    }

    public static Result success(String respMessage) {
        Result result = new Result();
        result.setRespCode(CODE.SUCCESS);
        result.setRespMessage(respMessage);
        return result;
    }

    public static Result fail(String respCode, String respMessage, Object data) {
        Result result = new Result();
        result.setData(data);
        result.setRespCode(respCode);
        result.setRespMessage(respMessage);
        return result;
    }
    public static Result fail(String respMessage, Object data) {
        Result result = new Result();
        result.setData(data);
        result.setRespCode("700");
        result.setRespMessage(respMessage);
        return result;
    }
    public static Result fail(String respMessage, String respCode){
        Result result = new Result();
        result.setRespCode(respCode);
        result.setRespMessage(respMessage);
        return result;
    }


    public static Result fail(Object data) {
        Result result = new Result();
        result.setData(data);
        result.setRespCode("700");
        return result;
    }

    public static Result fail(String respMessage) {
        Result result = new Result();
        result.setRespCode("700");
        result.setRespMessage(respMessage);
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setRespMessage(msg);
        result.setRespCode(CODE.FAIL);
        result.setData(null);
        return result;
    }

    public String getRespCode() {
        return respCode;
    }

    public void setRespCode(String respCode) {
        this.respCode = respCode;
    }

    public String getRespMessage() {
        return respMessage;
    }

    public void setRespMessage(String respMessage) {
        this.respMessage = respMessage;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
